package com.appspot.categoryeditor.work;

import org.slim3.datastore.Datastore;

import com.appspot.categoryeditor.meta.CategoryMeta;
import com.appspot.categoryeditor.meta.FolderMeta;
import com.appspot.categoryeditor.model.Category;
import com.appspot.categoryeditor.model.Folder;
import com.google.appengine.api.datastore.Key;

public class CreateSample {

	private final static FolderMeta FOLDER_META = FolderMeta.get();
	final static CategoryMeta CATEGORY_META = CategoryMeta.get();

	public static Folder createSampleFolderModel(Key userKey) {
		Folder folder = new Folder();
		Key folderKey = Datastore.createKey(userKey, FOLDER_META, "サンプル");
		folder.setId(folderKey);
		folder.setOrder(0);
		return folder;
	}

	public static Category
			createSampleCategoryModel(Key userKey, Folder folder) {
		
		Category category = new Category();
		Key categoryKey = Datastore.createKey(userKey, CATEGORY_META, "sample");
		category.setId(categoryKey);
		category.setName("サンプルカテゴリ");
		category.setOrder(1);
		category.setContent("[{\"data\":\"サンプル\",\"attr\":{\"class\":\" \"},\"state\":\"open\",\"children\":[{\"data\":\"ノード1\",\"attr\":{},\"state\":\"open\",\"children\":[{\"data\":\"ノード1-1\",\"attr\":{}},{\"data\":\"ノード1-2\",\"attr\":{\"class\":\" \"}}]},{\"data\":\"ノード2\",\"attr\":{\"class\":\" \"}}]}]");
		category.getFolderRef().setModel(folder);

		return category;
	}

}
